package day06;

/**
 * @author zdl
 * @date 2024/11/8
 */
public class Demo3 {
    public static void main(String[] args) {
        //// 1设计整型数组,要求计算出数组中数字的和
        int[] arr = {2,31,1,2};
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum = sum+arr[i];
        }
        double avg = sum * 1.0 / arr.length;
        System.out.println("数组中数字的和="+sum);
        System.out.println("平均值："+avg);
    }
}
